//导入封装好的 axios
import { request } from "@/utils/http";
import React from "react";
import type { HospitalSetItem, ReqAddHospitalParams, ReqHospitalSetListParams, ReqHospitalSetListResponse, ReqUpdateHospitalParams} from "./model/hospitalSetTypes";
// 请求医院设置列表的 req 
export function reqGetHospitalSetList({page,limit,hoscode,hosname}:ReqHospitalSetListParams){
    return request.get<any,ReqHospitalSetListResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`,{
        params:{
            hoscode,
            hosname
        }
    })
}


/**
 * 添加医院设置
 * @param hospital  ReqAddHospitalParams
 * @returns  promise null
 */
export function  reqAddHospital(hospital:ReqAddHospitalParams){
    return request.post<any,null>("/admin/hosp/hospitalSet/save",hospital);
}

/**
 * 获取单个医院信息
 * @param id string
 * @returns Promise HospitalSetItem
 */
export function reqgetHospital(id:string){
    return request.get<any,HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`)
}

/**
 * 修改医院
 * @param hospital ReqUpdateHospitalParams
 * @returns Promise null
 */
export function reqUpdateHospital(hospital:ReqUpdateHospitalParams){
    return request.put<any,null>("/admin/hosp/hospitalSet/update",hospital);
}

/**
 * 
 * @param id string
 * @returns Promise null
 */
export function reqRemoveHospital(id:number){
    return request.delete<any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

export function reqBatchRemoveHospitalList(arr:React.Key[]){
    return request.delete('/admin/hosp/hospitalSet/batchRemove',{
        //请求体 body
        data:arr
    })
}